<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      table {
        border: 1px solid black;
      }
    </style>
  </head>
  <body>
    <table>
      <tr>
        <td>第一个数</td>
        <td><input type="text" class="ipt1" /></td>
      </tr>
      <tr>
        <td>第二个数</td>
        <td><input type="text" class="ipt2" /></td>
      </tr>
      <tr>
        <td>
          <select name="" id="sele">
            <option value="+">+</option>
            <option value="-">-</option>
            <option value="*">*</option>
            <option value="/">/</option>
          </select>
        </td>
        <td><button>=</button></td>
      </tr>
      <tr>
        <td>运算结果</td>
        <td><input type="text" class="ipt3" /></td>
      </tr>
    </table>
  </body>
</html>
<script>
  var set = document.querySelector("#sele");
  var oIpt1 = document.querySelector(".ipt1");
  var oIpt2 = document.querySelector(".ipt2");
  var oIpt3 = document.querySelector(".ipt3");
  var oTon = document.querySelector("button");
  oTon.onclick = function () {
    if (set.value == "+") {
      oIpt3.value = oIpt1.value * 1 + oIpt2.value * 1;
    } else if (set.value == "-") {
      oIpt3.value = oIpt1.value * 1 - oIpt2.value * 1;
    } else if (set.value == "*") {
      oIpt3.value = oIpt1.value * 1 * oIpt2.value * 1;
    } else if (set.value == "/") {
      oIpt3.value = ((oIpt1.value * 1) / oIpt2.value) * 1;
    }
    console.log(oIpt3.value);
  };
</script>
